package com.woniu.finance.contorller;


import com.alibaba.fastjson.JSON;
import com.woniu.aop.OperationLogAnnotation;
import com.woniu.finance.entity.Asset;
import com.woniu.finance.entity.RequestParam;
import com.woniu.finance.service.IAssetService;
import com.woniu.util.utils.HttpResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 资产表 前端控制器
 * </p>
 *
 * @author 刘品水
 * @since 2023-04-25
 */
@RestController
@RequestMapping("/finance/asset")
@Slf4j
public class AssetController {
    @Autowired
    private IAssetService assetService;

    /**
     * @Description: 保存资产信息
     * @Param: [asset]
     * @return: com.woniu.util.utils.HttpResult<?>
     * @Author: 阿水
     * @Date: 2023/4/27
     */
    @PostMapping("saveAsset")
    @OperationLogAnnotation(operModul = "融资企业-新增资产表",operType = "新增",operDesc = "新增资产表")//操作日志注解
    public HttpResult<?> saveAsset(@RequestBody Asset asset) {
        log.info(JSON.toJSONString(asset));
        return assetService.saveAsset(asset);
    }

    /**
     * @Description: 根据id删除资产
     * @Param: [id]
     * @return: com.woniu.util.utils.HttpResult<?>
     * @Author: 阿水
     * @Date: 2023/4/27
     */
    @RequestMapping("removeAssetById")
    @OperationLogAnnotation(operModul = "融资企业-删除资产表",operType = "删除",operDesc = "删除资产表")//操作日志注解
    public HttpResult<?> removeAssetById(Integer id) {
        return assetService.removeAssetById(id);
    }

    /**
     * @Description: 修改资产信息
     * @Param: [asset]
     * @return: com.woniu.util.utils.HttpResult<?>
     * @Author: 阿水
     * @Date: 2023/4/27
     */

    @RequestMapping("modifyAsset")
    @OperationLogAnnotation(operModul = "融资企业-修改资产表",operType = "修改",operDesc = "修改资产表")//操作日志注解
    public HttpResult<?> modifyAsset(@RequestBody Asset asset) {
        return assetService.modifyAsset(asset);
    }

    /**
     * @Description: 根据id查询资产
     * @Param: [id]
     * @return: com.woniu.util.utils.HttpResult<?>
     * @Author: 阿水
     * @Date: 2023/4/27
     */
    @RequestMapping("findAssetById")
    @OperationLogAnnotation(operModul = "融资企业-根据id查询资产表",operType = "查询",operDesc = "根据id查询资产表")//操作日志注解
    public HttpResult<?> findAssetById(Integer id) {
        return assetService.findAssetById(id);
    }

    /**
     * @Description: 查询资产表
     * @Param: [id]
     * @return: com.woniu.util.utils.HttpResult<?>
     * @Author: 阿水
     * @Date: 2023/4/27
     */
    @RequestMapping("findAllAsset")
    @OperationLogAnnotation(operModul = "融资企业-查询所有资产表",operType = "查询",operDesc = "查询所有资产表")//操作日志注解
    public HttpResult<?> findAllAsset(@RequestBody RequestParam<Asset> param) {
        return assetService.findAllAsset(param);
    }

    /**
     * @Description: 查询资产表
     * @Param: [id]
     * @return: com.woniu.util.utils.HttpResult<?>
     * @Author: 阿水
     * @Date: 2023/4/27
     */
    @RequestMapping("findAllAssetByFinanceId")
    //传递的financeId为ownedEnterprise（切记）
    @OperationLogAnnotation(operModul = "融资企业-查询所有资产表",operType = "查询",operDesc = "查询所有资产表")//操作日志注解
    public HttpResult<?> findAllAssetByFinanceId(@RequestBody RequestParam<Asset> param) {
        return assetService.findAllAssetByFinanceId(param);
    }


}
